﻿@model BlogSite.Models.BlogCommentsViewModel

@{
    ViewBag.Title = "Details";
    BlogSite.Models.Comment comment = new BlogSite.Models.Comment(Model.Blog.BlogId, "", "", BlogSite.Models.Rating.Inappropriate);
}

<h2>Details</h2>

<div>
    <div class="form-group" style="float:left;">
        <h4>@Html.DisplayTextFor(model => model.Blog.Name)</h4>
    </div>
    <div class="form-group" style="float:right;">
            @Html.LabelFor(model => model.Blog.Topic, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DisplayTextFor(model => model.Blog.Topic)
            </div>
    </div>
   <hr />
    <dl class="dl-horizontal">
    </dl>
    <div class="form-horizontal" style="border: 1px solid #000000;">
        <hr />
        <div class="form-group">
            @Html.LabelFor(model => model.Blog.Post, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DisplayTextFor(model => model.Blog.Post)
            </div>
        </div>
    </div>

    
<table class="table">
    <tr>
        <th>
            Commenter
        </th>
        <th>
            Comment
        </th>
        <th>
            Comment Rating
        </th>
        <th></th>
    </tr>
@foreach (var item in Model.Comments) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Commenter)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.TheComment)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.CommenterRating)
        </td>
        <td>
            @Html.ActionLink("Edit Comment", "EditComment", new { commentid=item.CommentId, blogid=item.BlogId }) |
            @Html.ActionLink("Delete Comment", "DeleteComment", new { commentid=item.CommentId })
        </td>
    </tr>
    }
</table>
@using (Html.BeginForm("CreateComment", "Home")) 
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>Comment</h4>
        <hr />
        @Html.ValidationSummary(true)
        @Html.HiddenFor(x => comment.CommentId)
        @Html.HiddenFor(x => comment.BlogId)
        <div class="form-group">
            @Html.LabelFor(x => comment.Commenter, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(x => comment.Commenter)
                @Html.ValidationMessageFor(x => comment.Commenter)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(x => comment.TheComment, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(x => comment.TheComment)
                @Html.ValidationMessageFor(x => comment.TheComment)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(x => comment.CommenterRating, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownListFor(x => comment.CommenterRating, 
                Enum.GetValues(typeof(BlogSite.Models.Rating)).Cast<BlogSite.Models.Rating>().Select(v => new SelectListItem {
                    Text = v.ToString(), Value = ((int)v).ToString()}))
                @Html.ValidationMessageFor(x => comment.CommenterRating)
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create Comments" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
</div>

<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>